import { Injectable, NestMiddleware, Next, Req, Res } from "@nestjs/common"

@Injectable()
export class AuthorMiddleware implements NestMiddleware {
  use(@Req() req: any, @Res() res: any, @Next() next: any) {
    if (req.headers["authorization"] === "MaoJiuYuQi") {
      next()
    } else {
      res.json({
        status: "error",
        message: "令牌错误，无权操作！",
        code: "forbidden"
      })
    }
  }
}
